Uec3.SimpleCompanyMessageWindow = Ext.extend(Ext.app.Module, {
	id : 'simpleCompanyMessage',
	type : 'common/simpleCompanyMessage',

	/**
	 * Initialize this module. This function is called at startup (page
	 * load/refresh).
	 */
	init : function(initParams) {
	},
	paramsCollection : new Ext.util.MixedCollection(true),

	getParamsByKey : function(key) {
		return this.paramsCollection.get(key);
	},

	
	getComponents : function(params) {

		var simpleCompanyMessageForm;
		var componentSimpleCompanyMessageInits = function() {
		

			var formReader = new Ext.data.JsonReader(

			{
						root : 'root'
					}, [{
								name : 'id',
								type : 'int'
							}, {
								name : 'email',
								type : 'string'
							}, {
								name : 'name',
								type : 'string'
							}, {
								name : 'fax',
								type : 'string'
							}, {
								name : 'invoicAddress',
								type : 'string'
							}, {
								name : 'bankName',
								type : 'string'
							}, {
								name : 'bankCode',
								type : 'string'
							}, {
								name : 'qq',
								type : 'string'
							}, {
								name : 'msn',
								type : 'string'
							}, {
								name : 'web',
								type : 'string'
							}, 
							{
								name : 'contactor',
								type : 'string'
							}, {
								name : 'taxCode',
								type : 'string'
							}, {
								name : 'areaId',
								type : 'int'
							}, {
								name : 'code',
								type : 'string'
							}, {
								name : 'contactorIdentityCode'
							},{
								name : 'realType',
								type : 'int'
							}, {
								name : 'companyType',
								type : 'int'
							}, {
								name : 'realTypeName',
								type : 'string'
							}, {
								name : 'companyTypeName',
								type : 'string'
							}, {
								name : 'simpleName',
								type : 'string'
							}, {
								name : 'nameEn',
								type : 'string'
							}, {
								name : 'business',
								type : 'string'
							}, {
								name : 'postcode',
								type : 'string'
							}, {
								name : 'tel',
								type : 'string'
							}]

			);
			
			
           
			simpleCompanyMessageForm = new Ext.form.FormPanel({
						labelAlign : 'right',
						frame : true,
						labelWidth : 60,
						loadingText : '加载数据中...',
						buttonAlign : 'center',
						height:200,
						reader : formReader,
						url : '',
						items : [{
						             xtype:'fieldset',
						             title: '基本信息',
						             height:250,
						             collapsed: false,
						             items :[
						               {
						                 layout:'column',
						                 items:[
						                  {
						                    columnWidth:0.5,
						                    items:[
						                      {
						                       layout:'form',
						                       labelWidth:70,
						                       items:[{name : 'id',fieldLabel : '公司ID', xtype : 'hidden'},
						                         	{xtype:'textfield',fieldLabel:'公司名称', name:'name',width:150,anchor:'99%',style : {
													color : '#aaaaaa'
												},readOnly:true}]
						                      },{
						                       layout:'column',
						                       items:[{
						                           columnWidth:0.5,
						                           items:[{
						                                layout:'form',
						                                labelWidth:70,
						                                items:[{xtype:'textfield',fieldLabel:'负责人/法人',name:'contactor',anchor:'99%',style : {
															color : '#aaaaaa'
														},readOnly:true} ]}]
						                          },{
						                           columnWidth:0.5,
						                           items:[{
						                                layout:'form',
						                                labelAlign:'right',
						                                labelWidth:70,
						                                items:[{ xtype:'textfield',fieldLabel:'法人身份证',name:'contactorIdentityCode',anchor:'99%',style : {
															color : '#aaaaaa'
														},readOnly:true}]}]
						                         }
						                       ]
						                      }
						                     ,{
							                       layout:'column',
							                       items:[{
							                           columnWidth:0.5,
							                           items:[{
							                                layout:'form',
							                                labelWidth:70,
							                                items:[{xtype:'textfield',fieldLabel:'认证类型',name:'realTypeName',anchor:'99%',style : {
																color : '#aaaaaa'
															},readOnly:true} ]}]
							                          },{
							                           columnWidth:0.5,
							                           items:[{
							                                layout:'form',
							                                labelAlign:'right',
							                                labelWidth:70,
							                                items:[{ xtype:'textfield',fieldLabel:'公司类型',name:'companyTypeName',anchor:'99%',style : {
																color : '#aaaaaa'
															},readOnly:true}]}]
							                         }
							                       ]
							                      } 
						                      
						                      ]
						                  },{
						                    columnWidth:0.5,
						                    items:[{
						                       layout:'form',
						                       labelWidth:56,
						                       labelAlign:'right',
						                       items:[{xtype:'textfield',fieldLabel:'经营项目',name:'bussiness',anchor:'99%',style : {
													color : '#aaaaaa'
												},readOnly:true}]
						                      },{
						                       layout:'column',
						                       
						                       items:[{
						                           columnWidth:0.5,
						                           items:[{
						                                layout:'form',
						                                labelAlign:'right',
						                                labelWidth:56,
						                                items:[{xtype:'textfield',fieldLabel:'税号',name:'taxCode',anchor:'99%',style : {
															color : '#aaaaaa'
														},readOnly:true}]}]
						                         },{
						                           columnWidth:0.5,
						                           items:[{
						                                layout:'form',
						                                labelWidth:70,
						                                labelAlign:'right',
						                                items:[{xtype:'textfield',fieldLabel:'工商注册码',name:'code',anchor:'99%',style : {
															color : '#aaaaaa'
														},readOnly:true}]}]
						                         }]
						                       },{
							                       layout:'column',
							                       
							                       items:[{
							                           columnWidth:0.5,
							                           items:[{
							                                layout:'form',
							                                labelAlign:'right',
							                                labelWidth:56,
							                                items:[{xtype:'textfield',fieldLabel:'联系电话',name:'tel',anchor:'99%',style : {
																color : '#aaaaaa'
															},readOnly:true}]}]
							                         }]
							                       }]
						                     }]
						                   }]
						             }
						],

		buttons :[
		   {   
			text : '此公司就是我的往来单位',
			width:120,
			handler : function() {	
	
						Ext.Ajax.request({						
							
								url : Uec3.App.Constants.homeUrl+ '/partner/query_partner!updateMessage.do',
								success : function(res) {
									var result = Ext.decode(res.responseText);
									if (result.success == "OK") {
									  if(params.partner_win&&params.partner_ds){
										params.partner_win.buttons[0].show();
										params.partner_win.buttons[1].hide();
										params.partner_win.buttons[2].show();
										params.partner_win.buttons[3].show();
										params.partner_win.buttons[4].hide();
										var form =params.partner_win.items.get(0).getForm();
										form.findField("code").setReadOnly(true);
										form.findField("taxCode").setReadOnly(true);
										form.findField("bussiness").setReadOnly(true);
										form.findField("contactorIdentityCode").setReadOnly(true);
										form.findField("name").setReadOnly(true);
										form.findField("contactor").setReadOnly(true);
										form.findField("companyId").setValue(params.id);3
										params.partner_ds.reload();
									}
										Ext.Msg.alert('提示', "该认证公司已经成功加为你的往来单位");

									} else {
										Ext.Msg.alert("提示", result.failure);
									}
								},
								failure : function(res) {
									Ext.Msg.alert('提示', "更新信息失败");
								},
								//客户ID和客户所在的公司ID
								params : {partnerId : params.partnerId,companyId:params.id}
					    });
      
			      
			        
				}

		},{
					text : '关闭',

					handler : function() {

			simpleCompanyMessageForm.ownerCt.close();

					},
					style : "margin-left:20px"
				}]
			});
			
			// 加载form表单数据
			simpleCompanyMessageForm.getForm().load({
				url : Uec3.App.Constants.homeUrl
						+ '/company/query_company!queryCompany.do',
						
						params : {
							companyId : params.id
					},					method : "post",
					waitMsg : '正在加载数据...',	
                      success : function(form, action) {
			                
	                       // Ext.MessageBox.alert("提示","加载数据成功");
							
					},

						failure : function(form, action) {
			                
							Ext.MessageBox.alert("提示","加载数据失败");
					}		
			});
			
		}

		function simpleCompanyMessageControlEvent() {
		
			
			simpleCompanyMessageForm.on("render",function(form){
		
				if(params.isHiddenButton){
				
					form.buttons[0].hide();
				
			}
				
			});
			
		
		}
		componentSimpleCompanyMessageInits();

		simpleCompanyMessageControlEvent();

		return simpleCompanyMessageForm;
	},
	/**
	 * Create this modules window here.
	 */
	createWindow : function(params) {
		
		var desktop = Uec3.App.getDesktop();
		var win = desktop.getWindow("simpleCompanyMessage");
		if (!win) {
			win = desktop.createWindow({
						id : "simpleCompanyMessage",
						title : '基本信息',
						width :900,
						height :200,
						iconCls : 'acc-icon',
						shim : false,
						modal : true,
						plain : true,
						animCollapse : false,
						constrainHeader : true,
						maximizable : false,
						resizable : false,
						listeners:{"beforeshow":function(){
							
						}
			},
						taskbuttonTooltip : "基本信息",
						layout : "fit",
						tools : [{
									id : 'refresh',
									handler : Ext.emptyFn,
									scope : this
								}],
						items : [this.getComponents(params)]
					});

		}
		win.show();

	}
});